let str = "abbbacadc"
function reset(str) {
  let result = []
  for (let i = 0; i < str.length; i++) {
    let len = result.length
    if (result[len - 1] != str[i]) {
      result.push(str[i])
    }
    else {
      if (str[i + 1] != result[len - 1]) {
        result.pop()
      }
    }
  }
  return result.join("")
}
console.log(reset(str))